package com.carbon.notice.controller;


import com.carbon.model.Result;
import com.carbon.notice.dto.CarbonNoticeDTO;
import com.carbon.notice.entity.CarbonNotice;
import com.carbon.notice.service.ICarbonNoticeService;
import com.carbon.notice.vo.CarbonVO;
import com.netflix.discovery.converters.Auto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 碳咨询公告表 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-06-29
 */
@RestController
@RequestMapping("/notice")
public class CarbonNoticeController {

    @Autowired
    private ICarbonNoticeService carbonNoticeService;

    /**
     * 条件查询资讯公告列表
     * @param vo
     * @return
     */
    @GetMapping ("/list")
    public Result getCarbonList(CarbonVO vo){
        Result result = new Result();
        List<CarbonNotice> carbonNoticeList = carbonNoticeService.getCarbonNoticeList(vo);
        result.setResult(carbonNoticeList);
        return result;
    }

    /**
     * 资讯公告新增
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public Result addCarbonNotice(CarbonNoticeDTO dto){
        boolean b = carbonNoticeService.addCarbonNotice(dto);
        return new Result(b);
    }

    /**
     * 资讯公告删除
     * @param id
     * @return
     */
    @PostMapping("/del")
    public Result delCarbonNotice(Integer id){
        boolean b = carbonNoticeService.delCarbonNotice(id);
        return new Result(b);
    }






}
